/*
 * @(#)DocumentInfoTag.java
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */
package com.dcivision.dms.taglib;

import java.io.IOException;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.BodyTagSupport;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.dcivision.alert.bean.UpdateAlert;
import com.dcivision.alert.core.AlertManager;
import com.dcivision.dms.DmsOperationConstant;
import com.dcivision.dms.bean.DmsDefaultProfileSetting;
import com.dcivision.dms.bean.DmsDocument;
import com.dcivision.dms.bean.DmsRoot;
import com.dcivision.dms.bean.DmsVersion;
import com.dcivision.dms.bean.MtmDocumentRelationship;
import com.dcivision.dms.core.DocumentRetrievalManager;
import com.dcivision.dms.dao.DmsArchiveDAObject;
import com.dcivision.dms.dao.DmsArchiveDetailDAObject;
import com.dcivision.dms.dao.DmsDocumentDAObject;
import com.dcivision.dms.dao.DmsRootDAObject;
import com.dcivision.dms.dao.MtmDocumentRelationshipDAObject;
import com.dcivision.framework.GlobalConstant;
import com.dcivision.framework.MessageResourcesFactory;
import com.dcivision.framework.PermissionManager;
import com.dcivision.framework.SessionContainer;
import com.dcivision.framework.SystemFunctionConstant;
import com.dcivision.framework.SystemParameterConstant;
import com.dcivision.framework.SystemParameterFactory;
import com.dcivision.framework.TextUtility;
import com.dcivision.framework.Utility;
import com.dcivision.framework.taglib.html.FormTag;

/**
 * <p>Class Name:    DocumentInfoTag.java    </p>
 * <p>Description:   This tag is the layout the dms detail according to the documentID in DOCUMENT_ID
 * @author           Phoebe Wong
 * @company          DCIVision Limited
 * @creation date    12/08/2003
 * @version          $Revision: 1.192.2.30 $
 */

public class DocumentInfoTag extends ExtImgTag {

  public static final String REVISION = "$Revision: 1.192.2.30 $";
  
  private static final Log log = LogFactory.getLog(DocumentInfoTag.class);
  
  int iscreenSize = -1;
        //TextUtility.parseInteger((String)(this.pageContext.getSession().getAttribute(GlobalConstant.CLIENT_SCREEN_WIDTH_KEY)));
  int idefaultLength ;
  int isize640;
  int isize800;
  int isize1024;
  int isize1152;
  int isize1280;
  int isize1281;

  private DmsDocument docObject = null;
  private String sVersion = null;
  private String sPermission=null;
  private DmsDocument rootDocument=null;
  private boolean bInviteToRead = false;
  private String sCurFunctionCode = null;
  
  private boolean bShowIndexFlag = true;
  private boolean bOnClick = true;  //cater the folder location; to disable the link
  private int limitLength = -1;
  public final static int USE_SHORT_DOCUMENT_NAME = -2;
  private boolean isLimitLength = true;//TC.ADD
  
  private String pageFlag = "";
  
  private boolean hasUnderLine = true;

  /* define a variable for linking to download or view page. */
  private boolean bLinkFlag= false;
  private boolean bPopupFlag = false;
  private String blinkFlagStr ="";

  
  //define a variable for show index or not.
  private boolean isOverLib=false;
  private String indexFlag="showIndexFlag";
  private String recordStatus = null;        //used to check the record is a empty reference file or not.

  /* Variable used for system log action */
  Integer updateAlertID = null;
  Integer updateAlertTypeID = null;
  Integer updateAlertSystemLogID = null;
  private boolean updateReadOperation = false;

  private SessionContainer sessionContainer;
  private List result;
  
  private boolean showIndexLayer  = false;
  private boolean checkWindowForAction = false;
  
  private boolean throughDocStatus = false; 
  
  StringBuffer docInfo = null;
  JspWriter out = null;

  FormTag formTag = null;

  Connection conn = null;
  
  String contextPath = null;
  
  /**
   * Constructor
   */
  public int getDefaultValue() {
    if(isLimitLength){
      if (USE_SHORT_DOCUMENT_NAME == limitLength){
        if (TextUtility.hasSBCCase(this.getFileName())){
          return DmsOperationConstant.DEFAULT_SBC_LIMIT_LENGTH;
        } else {
          return DmsOperationConstant.DEFAULT_DBC_LIMIT_LENGTH;
        }
      }
      this.iscreenSize = TextUtility.parseInteger(this.pageContext.getSession().getAttribute(GlobalConstant.CLIENT_SCREEN_WIDTH_KEY).toString() );
      if(iscreenSize <= 640){
        idefaultLength = isize640;
      }else if(iscreenSize <= 800 && iscreenSize >640 ){
        idefaultLength = isize800;
      }else if(iscreenSize <= 1024 && iscreenSize >800 ){
        idefaultLength = isize1024;
      }else if(iscreenSize <= 1152 && iscreenSize >1024 ){
        idefaultLength = isize1152;
      }else if(iscreenSize <= 1280 && iscreenSize >1152 ){
        idefaultLength = isize1280;
      }else{
        idefaultLength = isize1281 ;
      }
      return idefaultLength;
    }else{
      return isize1281;//big
    }
    /**/
  }

  public DocumentInfoTag() {
    super();
  }

  public DmsDocument getDocObject() {
    return this.docObject;
  }

  public void setVersion(String version) {
    this.sVersion = version;
  }

  public String getVersion() {
    return this.sVersion;
  }

  public void setDocObject(DmsDocument docObject) {
    this.docObject = docObject;
  }

  public void setPermission(String permission) {
    this.sPermission = permission;
  }

  public String getPermission(){
    return this.sPermission;
  }

  public void setRootDocument(DmsDocument rootDoc){
    this.rootDocument = rootDoc;
  }

  public DmsDocument getRootDocument(){
    return this.rootDocument;
  }

  public void setInviteToRead(boolean inviteToRead){
    this.bInviteToRead = inviteToRead;
  }

  public boolean getInviteToRead(){
    return this.bInviteToRead;
  }

  public void setCurFunctionCode(String curFunctionCode){
    this.sCurFunctionCode = curFunctionCode;
  }

  public String getCurFunctionCode(){
    return this.sCurFunctionCode;
  }

  public void setShowIndexFlag(boolean indexFlag){
    this.bShowIndexFlag = indexFlag;
  }

  public boolean getShowIndexFlag() {
    return this.bShowIndexFlag;
  }

  public void setIndexFlag(String indexFlag) {
    this.indexFlag = indexFlag;
  }

  public String getIndexFlag() {
    return this.indexFlag;
  }

  public void setRecordStatus(String recordStatus) {
    this.recordStatus = recordStatus;
  }

  public String getRecordStatus() {
    return this.recordStatus;
  }

  public boolean getOnClick(){
    return this.bOnClick;
  }

  public void setOnClick(boolean onClick){
    this.bOnClick = onClick;
  }
  
  public boolean getShowIndexLayer(){
    return this.showIndexLayer;
  }
  
  public void setShowIndexLayer(boolean showIndexLayer){
    this.showIndexLayer=showIndexLayer;
  }

  /**
   * set value to sLinkFlag
   * @param sLinkFlag
   */
  public void setLinkFlag(boolean bLinkFlag) {
    this.bLinkFlag = bLinkFlag;
    this.blinkFlagStr ="blinkFlagStr";
  }

  /**
   * get value of sLinkFlag
   * @return sLInkFlag
   */
  public boolean getLinkFlag() {
    return this.bLinkFlag;
  }

  /**
   * set value to bPopupFlag
   * @param bPopupFlag
   */
  public void setPopupFlag(boolean bPopupFlag) {
    this.bPopupFlag = bPopupFlag;
  }

  /**
   * get value of bPopupFlag
   * @return bPopupFlag
   */
  public boolean getPopupFlag() {
    return this.bPopupFlag;
  }

  /**
   * set value to isOverLib
   * @param isOverLib
   */
  public void setIsOverLib(boolean isOverLib) {
    this.isOverLib = isOverLib;
  }

  /**
   * get value of isOverLib
   * @return isOverLib
   */
  public boolean getIsOverLib() {
    return this.isOverLib;
  }

  /**
   * set value to updateAlertID
   * @param updateAlertID
   */
  public void setUpdateAlertID(Integer updateAlertID) {
    this.updateAlertID = updateAlertID;
  }

  /**
   * get value of updateAlertID
   * @return updateAlertID
   */
  public Integer getUpdateAlertID() {
    return this.updateAlertID;
  }

  /**
   * set value to updateAlertTypeID
   * @param updateAlertTypeID
   */
  public void setUpdateAlertTypeID(Integer updateAlertTypeID) {
    this.updateAlertTypeID = updateAlertTypeID;
  }

  /**
   * get value of updateAlertTypeID
   * @return updateAlertTypeID
   */
  public Integer getUpdateAlertTypeID() {
    return this.updateAlertTypeID;
  }

  /**
   * set value to updateAlertSystemLogID
   * @param updateAlertSystemLogID
   */
  public void setUpdateAlertSystemLogID(Integer updateAlertSystemLogID) {
    this.updateAlertSystemLogID = updateAlertSystemLogID;
  }

  /**
   * get value of updateAlertSystemLogID
   * @return updateAlertSystemLogID
   */
  public Integer getUpdateAlertSystemLogID() {
    return this.updateAlertSystemLogID;
  }

  public void setUpdateReadOperation(boolean updateReadOperation){
    this.updateReadOperation = updateReadOperation;
  }

  public boolean getUpdateReadOperation(){
    return this.updateReadOperation;
  }

  public int getLimitLength() {
    return (this.limitLength);
  }

  public void setLimitLength(int limitLength) {
    this.limitLength = limitLength;
  }
  
  public String getPageFlag() {
    return pageFlag;
  }

  public void setPageFlag(String pageFlag) {
    this.pageFlag = pageFlag;    
  }
  
  public boolean getThroughDocStatus(){
    return this.showIndexLayer;
  }
  
  public void setThroughDocStatus(boolean throughDocStatus){
    this.throughDocStatus=throughDocStatus;
  }
  
  /**
   * Method called at start of tag
   * @return a SKIP_BODY
   */
  public int doStartTag() throws JspException {
    init();
    if (this.recordStatus==null) {
      this.recordStatus = "";
    }
    this.setFileName(docObject.getDocumentName());
    this.setDocType(docObject.getDocumentType());
    out=pageContext.getOut();
    contextPath=(String)this.pageContext.getServletContext().getAttribute(GlobalConstant.CONTEXT_PATH_KEY);
    formTag=(FormTag)BodyTagSupport.findAncestorWithClass(this, FormTag.class);
    sessionContainer=(SessionContainer)this.pageContext.getSession().getAttribute(GlobalConstant.SESSION_CONTAINER_KEY);
    conn=(Connection) pageContext.getRequest().getAttribute(GlobalConstant.DB_KEY);
    return SKIP_BODY;
  }
  
  protected void init() {
    bPopupFlag = TextUtility.parseBoolean(SystemParameterFactory.getSystemParameter(SystemParameterConstant.DMS_SHOW_DOCUMENT_SUMMARY_ON_POPUP));
    bLinkFlag= TextUtility.parseBoolean(SystemParameterFactory.getSystemParameter(SystemParameterConstant.DMS_SHOW_DOCUMENT_SUMMARY));
    isize640 = SystemParameterFactory.getSystemParameterInteger(SystemParameterConstant.DMS_MAX_WORDS_OF_TITLE_BY_SCREEN_WIDTH_640).intValue();
    isize800 = SystemParameterFactory.getSystemParameterInteger(SystemParameterConstant.DMS_MAX_WORDS_OF_TITLE_BY_SCREEN_WIDTH_800).intValue();
    isize1024 = SystemParameterFactory.getSystemParameterInteger(SystemParameterConstant.DMS_MAX_WORDS_OF_TITLE_BY_SCREEN_WIDTH_1024).intValue();
    isize1152 = SystemParameterFactory.getSystemParameterInteger(SystemParameterConstant.DMS_MAX_WORDS_OF_TITLE_BY_SCREEN_WIDTH_1152).intValue();
    isize1280 = SystemParameterFactory.getSystemParameterInteger(SystemParameterConstant.DMS_MAX_WORDS_OF_TITLE_BY_SCREEN_WIDTH_1280).intValue();
    isize1281 = SystemParameterFactory.getSystemParameterInteger(SystemParameterConstant.DMS_MAX_WORDS_OF_TITLE_BY_SCREEN_WIDTH_1281).intValue();
  }

  public int doEndTag() throws JspException {  
    docInfo= new StringBuffer();
    limitLength = getDefaultValue();
    sPermission = TextUtility.noNull(sPermission);

    try {        
      if(Utility.isEmpty(blinkFlagStr)){
        bLinkFlag = TextUtility.parseBoolean(SystemParameterFactory.getSystemParameter(SystemParameterConstant.DMS_SHOW_DOCUMENT_SUMMARY));     
      }

      result = new ArrayList();

      if (DmsDocument.DOCUMENT_LINK.equals(this.docObject.getDocumentType())) {
        this.processDocumentLink();     
      }else if(DmsDocument.DOCUMENT_TYPE.equals(this.docObject.getDocumentType())){
        this.processDocument();
      }else if(DmsDocument.FOLDER_TYPE.equals(this.docObject.getDocumentType())){
        this.processFolder();
      }else if (DmsDocument.COMPOUND_DOC_TYPE.equals(this.docObject.getDocumentType())){
        this.processCompoundDoc();
      }else if (DmsDocument.PAPER_DOC_TYPE.equals(this.docObject.getDocumentType())){
        this.processPaperDoc();
      }else if(DmsDocument.EMAIL_DOC_TYPE.equals(this.docObject.getDocumentType())){
        this.processEmailDoc();
      }else if(DmsDocument.FORM_DOC_TYPE.equals(this.docObject.getDocumentType())){
        this.processFormDoc();
      }else if(DmsDocument.FLOW_DOC_TYPE.equals(this.docObject.getDocumentType())){
        this.processFlowDoc();
      }else if(DmsDocument.ORIGINSLITY_EMAIL_TYPE.equals(this.docObject.getDocumentType())){
        this.processEmail();
      }
    } catch (Exception e) {
      log.error(e,e);
      throw new JspException(e);
    } finally {
      this.release();
    }
    return EVAL_PAGE;
  }
  
  /**
   * Method processed short cut document.
   * 
   */
  private void processDocumentLink(){ 
    String tempType = null;
    DmsDocumentDAObject dmsDocmentDAO = new DmsDocumentDAObject(sessionContainer, conn);
    com.dcivision.dms.core.DocumentRetrievalManager docRetrievalManager = new com.dcivision.dms.core.DocumentRetrievalManager(sessionContainer, conn);
    try{
    	DmsDocument targetDoc = null;
    	if (GlobalConstant.RECORD_STATUS_INACTIVE.equals(this.docObject.getRecordStatus())){
    		MtmDocumentRelationshipDAObject relationshipDAO = new MtmDocumentRelationshipDAObject(sessionContainer, conn);
    		//Joan.Xiong update code for bug EIP-165 by 2006/09/18
    		//List relationshipIDs = relationshipDAO.getRelatedDocIDByDocID(this.docObject.getID(),DmsDocument.DOCUMENT_LINK,GlobalConstant.RECORD_STATUS_INACTIVE);
    		List relationshipIDs = relationshipDAO.getInactiveListByRelationID(this.docObject.getID(),DmsDocument.DOCUMENT_LINK,GlobalConstant.RECORD_STATUS_INACTIVE);
    		//Joan.Xiong update code end
    		Integer relationshipID = null;
    		if (!Utility.isEmpty(relationshipIDs) && relationshipIDs.size() > 0){
    			MtmDocumentRelationship mtmDoc = (MtmDocumentRelationship)relationshipIDs.get(0);
    			relationshipID = mtmDoc.getDocumentID();
    		}
    		targetDoc = (DmsDocument)dmsDocmentDAO.getByIDRecordStatus(relationshipID,null); 		
    	} else {
    		targetDoc =docRetrievalManager.getRelationshipTargetDocument(this.docObject.getID(),this.docObject.getDocumentType());
    	}
    	
//      DmsDocument targetDoc =docRetrievalManager.getRelationshipTargetDocument(this.docObject.getID(),this.docObject.getDocumentType());
      if(targetDoc!=null){
        while(DmsDocument.DOCUMENT_LINK.equals(targetDoc.getDocumentType())){
          targetDoc =docRetrievalManager.getRelationshipTargetDocument(targetDoc.getID(),targetDoc.getDocumentType());
        }
        tempType =targetDoc.getDocumentType();
        
        if (DmsDocument.COMPOUND_DOC_TYPE.equals(tempType)){
        	this.setExtension("CMP");
        } else if (DmsDocument.PAPER_DOC_TYPE.equals(tempType)){
          this.setExtension("PAPER");
        } else if (DmsDocument.EMAIL_DOC_TYPE.equals(tempType)){
          this.setExtension("EML");
        } else {
        	this.setExtension(TextUtility.getExtension(targetDoc.getDocumentName()));
        }
      }
      if(!DmsDocument.FOLDER_TYPE.equals(tempType)){
        super.doEndTag();       
      }else{
        out.print("<img ");
        out.print("src=\"" + imgSrc("IconDMSFolderShortcut.gif") + "\" ");
        out.print("align=\"absmiddle\" ");
        out.print("/>");
      }
      if (DmsDocument.DOCUMENT_LINK.equals(docObject.getDocumentType())) {
        /* Used to update the doc link name and type; Wont infulence the getDocumentProfileInfo() */
        if (targetDoc!=null){
          targetDoc.setDocumentName(this.docObject.getDocumentName());
          targetDoc.setDocumentType(this.docObject.getDocumentType());
          result = dmsDocmentDAO.getDocumentProfileInfo(targetDoc,sVersion);
        }
      } else {
        result = dmsDocmentDAO.getDocumentProfileInfo(this.docObject,sVersion);
      }
      
      //get StringBuffer docInfo
      this.showHead();
      this.showArchvieInfo();
      this.showReferenceInfo(targetDoc);
      this.showDefaultProfileInfo(targetDoc);
      this.showProfileInfo();
      this.showEndTable();
      
      String imgURL="";
      
      //get file name.
      String sFileName = this.getFileName(); //to display all space
      if (sFileName.length() > this.limitLength){
        sFileName = sFileName.substring(0,this.limitLength).replaceAll(" ", "&nbsp;")+"...";
      }
      
      PermissionManager permissionManager = this.sessionContainer.getPermissionManager();
      boolean isReadRight = permissionManager.hasAccessRight(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, this.docObject.getID(), "R");
      boolean isTargetReadRight = (targetDoc!=null ? permissionManager.hasAccessRight(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, targetDoc.getID(), "R") : false);
      boolean isStatusInActive = GlobalConstant.STATUS_INACTIVE.equals(recordStatus);
      boolean isTargetArchived = (targetDoc!=null && DmsVersion.ARCHIVED_STATUS.equals(targetDoc.getItemStatus()));
      
      String sStyle = null;
      
      if (!isReadRight || !isTargetReadRight || isStatusInActive || isTargetArchived) {
        // if shortcut not permission, target archived or status inactive, then show document name only.
        sStyle = "";//"archived";
        printFileNameWithStyle(out,sStyle,sFileName);
      } else {
        sStyle = this.getAlertFileNameStyle();
        if(DmsDocument.DOCUMENT_TYPE.equals(tempType)){
          imgURL=this.imgSrc();
        }else if(DmsDocument.FOLDER_TYPE.equals(tempType)){
          imgURL=this.imgSrc("IconDMSFolder.gif");
        }else if(DmsDocument.COMPOUND_DOC_TYPE.equals(tempType)){
          imgURL=this.imgSrc("IconDMSFileExtCOMPOUND.gif");
        }else if(DmsDocument.FOLDER_TYPE.equals(tempType)){
          imgURL=this.imgSrc("IconDMSPaperDoc.gif");  
        }else if (DmsDocument.EMAIL_DOC_TYPE.equals(tempType)){
        	imgURL=this.imgSrc("IconDMSEmailDoc.gif");
        }else{
          imgURL=this.imgSrc("IconDMSFileExtUNKNOWN.gif");  
        }
        
        //get onClick url.
        String onClickURL=this.getOnClickURL();
        
        if (!Utility.isEmpty(targetDoc)){
          //print with style.
          if(bOnClick && !GlobalConstant.STATUS_INACTIVE.equals(this.getDocObject().getRecordStatus())){
            printFileStyle(sStyle,sFileName,onClickURL,imgURL);
          }else{
            if (hasUnderLine){
              printFolderShortFileName(sFileName,sStyle); 
            } else {
              if (bShowIndexFlag) {
                StringBuffer sbLink = new StringBuffer();
                if(this.getShowIndexLayer() || !docObject.getItemStatus().equals("R")){
                  sbLink.append("<span onmouseover=\"return getDocumentInfo('" +docInfo.toString() + "');\" onmouseout=\"return nd();\"");
                }
                if(sbLink.length()>0){
                  sbLink.append(">");
                }
                out.print(" "+sbLink.toString());
                printFontFileName(out,sFileName,sStyle);
                if(sbLink.length()>0){
                  out.print("</span>");
                }
              }
            }
          }
        }else{
          printFileStyle(sStyle,sFileName,onClickURL,imgURL);
        }
      }
      
      
      if (this.throughDocStatus == false && GlobalConstant.STATUS_INACTIVE.equals(recordStatus)) {
        out.print("</strike>");
      }
      
      if (isTargetArchived) {
        out.println("&nbsp;<img src=\"" + this.imgSrc("IconArchived.gif")  + "\" border=\"0\" align=\"absmiddle\" alt=\"" + MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "common.label.target_document_was_archived") + "\">");
      }

    }catch(Exception e){}
  }
  
  /**
   * Method processed general docuement.
   *
   */
  private void processDocument(){   
    try{
      super.doEndTag();
    
      DmsDocumentDAObject dmsDocmentDAO = new DmsDocumentDAObject(sessionContainer, conn);
      result = dmsDocmentDAO.getDocumentProfileInfo(this.docObject,sVersion);
    
      //get StringBuffer docInfo
      this.showHead();
      this.showArchvieInfo();
      this.showVersionInfo();
      this.showReferenceInfo(null);
      this.showDefaultProfileInfo();
      this.showProfileInfo();
      this.showEndTable();
    
      String sStyle=this.getAlertFileNameStyle();      
      String imgURL="";
      
      //get file name.
      String sFileName = this.getFileName(); //to display all space
      if (sFileName.length() > this.limitLength){
        sFileName = sFileName.substring(0,this.limitLength).replaceAll(" ", "&nbsp;")+"...";
      }
    
      //get onClick url.
      String onClickURL=this.getOnClickURL();

      if (this.throughDocStatus == false && GlobalConstant.STATUS_INACTIVE.equals(recordStatus.trim())){ 
        printFileNameWithStyle(out,sStyle,sFileName);
      }else if (!GlobalConstant.RECORD_STATUS_ACTIVE.equals(this.docObject.getRecordStatus())) {
        printFileNameWithStyle(out,sStyle,sFileName);
      } else {
        imgURL=this.imgSrc();
        this.printFileStyle(sStyle,sFileName,onClickURL,imgURL);
      }
      
      if (this.throughDocStatus == false && GlobalConstant.STATUS_INACTIVE.equals(recordStatus)) {
        out.print("</strike>");
      }
      
    }catch(Exception e){}
  }
  
  /**
   * Method processed general folder.
   *
   */
  private void processFolder(){   
    try{
      super.doEndTag();
    
      DmsDocumentDAObject dmsDocmentDAO = new DmsDocumentDAObject(sessionContainer, conn);
      result = dmsDocmentDAO.getDocumentProfileInfo(this.docObject,sVersion);
    
      //get StringBuffer docInfo
      this.showHead();
      this.showArchvieInfo();
      this.showReferenceInfo(null);
      this.showDefaultProfileInfo();
      this.showProfileInfo();
      this.showEndTable();
    
      String sStyle=this.getAlertFileNameStyle();      
      
      //get file name.
      String sFileName = this.getFileName(); //to display all space
      if (sFileName.length() > this.limitLength){
        sFileName = sFileName.substring(0,this.limitLength).replaceAll(" ", "&nbsp;")+"...";
      }
      
      if (this.throughDocStatus == false && GlobalConstant.STATUS_INACTIVE.equals(recordStatus.trim())){ 
        printFileNameWithStyle(out,sStyle,sFileName);
      }else if (!GlobalConstant.RECORD_STATUS_ACTIVE.equals(this.docObject.getRecordStatus())) {
        // if folder is deleted or is in pending status, not allow show link / lee 06/12/13 EIP-1030
        printFileNameWithStyle(out,sStyle,sFileName);
      }else {
        this.printFolderURL(sFileName,sStyle);
      }
      
      if (this.throughDocStatus == false && GlobalConstant.STATUS_INACTIVE.equals(recordStatus)) {
        out.print("</strike>");
      }
      
    }catch(Exception e){}
  }
  
  /**
   * Method processed compound document.
   *
   */
  protected void processCompoundDoc(){
    try{
      this.setExtension("CMP");    
      super.doEndTag();
   
      DmsDocumentDAObject dmsDocmentDAO = new DmsDocumentDAObject(sessionContainer, conn);
      result = dmsDocmentDAO.getDocumentProfileInfo(this.docObject,sVersion);
    
      //get StringBuffer docInfo
      this.showHead();
      this.showArchvieInfo();
      this.showVersionInfo();
      this.showReferenceInfo(null);
      this.showDefaultProfileInfo();
      this.showProfileInfo();
      this.showEndTable();
    
      String sStyle=this.getAlertFileNameStyle();      
      String imgURL="";
      
      //get file name.
      String sFileName = this.getFileName(); //to display all space
      if (sFileName.length() > this.limitLength){
        sFileName = sFileName.substring(0,this.limitLength).replaceAll(" ", "&nbsp;")+"...";
      }
      
      //get click url.
      String onClickURL=this.getOnClickURL();
    
      if (this.throughDocStatus == false && GlobalConstant.STATUS_INACTIVE.equals(recordStatus.trim())){ 
        printFileNameWithStyle(out,sStyle,sFileName);
      }else if (!GlobalConstant.RECORD_STATUS_ACTIVE.equals(this.docObject.getRecordStatus())) {
        printFileNameWithStyle(out,sStyle,sFileName);
      } else {
        imgURL=this.imgSrc("IconDMSFileExtCOMPOUND.gif");
        this.printFileStyle(sStyle,sFileName,onClickURL,imgURL);
      }
      
      if (this.throughDocStatus == false && GlobalConstant.STATUS_INACTIVE.equals(recordStatus)) {
        out.print("</strike>");
      }
      
    }catch(Exception e){}
  }
  
  /**
   * Method processed Paper document.
   *
   */
  protected void processPaperDoc(){
    try{
      this.setExtension("PAPER");
      super.doEndTag();
    
      DmsDocumentDAObject dmsDocmentDAO = new DmsDocumentDAObject(sessionContainer, conn);
      result = dmsDocmentDAO.getDocumentProfileInfo(this.docObject,sVersion);
    
      //get StringBuffer docInfo
      this.showHead();
      this.showArchvieInfo();
      this.showVersionInfo();
      this.showReferenceInfo(null);
      this.showDefaultProfileInfo();
      this.showProfileInfo();
      this.showEndTable();
    
      String sStyle=this.getAlertFileNameStyle();      
      String imgURL="";
    
      String sFileName = this.getFileName(); //to display all space
      if (sFileName.length() > this.limitLength){
        sFileName = sFileName.substring(0,this.limitLength).replaceAll(" ", "&nbsp;")+"...";
      }
      
      //get click url.
      String onClickURL=this.getOnClickURL();
    
      if (this.throughDocStatus == false && GlobalConstant.STATUS_INACTIVE.equals(recordStatus.trim())){ 
        printFileNameWithStyle(out,sStyle,sFileName);
      }else if (!GlobalConstant.RECORD_STATUS_ACTIVE.equals(this.docObject.getRecordStatus())) {
        printFileNameWithStyle(out,sStyle,sFileName);
      } else {
        imgURL=this.imgSrc("IconDMSPaperDoc.gif"); 
        this.printFileStyle(sStyle,sFileName,onClickURL,imgURL);
      }   
      
      if (this.throughDocStatus == false && GlobalConstant.STATUS_INACTIVE.equals(recordStatus)) {
        out.print("</strike>");
      }
      
    }catch(Exception e){}
  }
  
  /**
   * Method processed Email document.
   *
   */
  protected void processEmailDoc(){
    try{
      this.setExtension("EMAIL");    
      super.doEndTag();
   
      DmsDocumentDAObject dmsDocmentDAO = new DmsDocumentDAObject(sessionContainer, conn);
      result = dmsDocmentDAO.getDocumentProfileInfo(this.docObject,sVersion);
    
      //get StringBuffer docInfo
      this.showHead();
      this.showArchvieInfo();
      this.showVersionInfo();
      this.showReferenceInfo(null);
      //this.showDefaultProfileInfo();
      this.showProfileInfo();
      this.showEndTable();
    
      String sStyle=this.getAlertFileNameStyle();      
      String imgURL="";
      
      //get file name.
      String sFileName = this.getFileName(); //to display all space
      if (sFileName.length() > this.limitLength){
        sFileName = sFileName.substring(0,this.limitLength).replaceAll(" ", "&nbsp;")+"...";
      }
      
      //get click url.
      String onClickURL=this.getOnClickURL();
    
      if (this.throughDocStatus == false && GlobalConstant.STATUS_INACTIVE.equals(recordStatus.trim())){ 
        printFileNameWithStyle(out,sStyle,sFileName);
      }else if (!GlobalConstant.RECORD_STATUS_ACTIVE.equals(this.docObject.getRecordStatus())) {
        printFileNameWithStyle(out,sStyle,sFileName);
      } else {
        imgURL=this.imgSrc("IconTreeEmailDocOpen.gif");
        this.printFileStyle(sStyle,sFileName,onClickURL,imgURL);
      }
      
      if (this.throughDocStatus == false && GlobalConstant.STATUS_INACTIVE.equals(recordStatus)) {
        out.print("</strike>");
      }
      
    }catch(Exception e){}
  }
  
  protected void processEmail(){
    try{
      super.doEndTag();
    
      DmsDocumentDAObject dmsDocmentDAO = new DmsDocumentDAObject(sessionContainer, conn);
      result = dmsDocmentDAO.getDocumentProfileInfo(this.docObject,sVersion);
    
      //get StringBuffer docInfo
      this.showHead();
      this.showArchvieInfo();
      this.showVersionInfo();
      this.showReferenceInfo(null);
      this.showDefaultProfileInfo();
      this.showProfileInfo();
      this.showEndTable();
    
      String sStyle=this.getAlertFileNameStyle();      
      String imgURL="";
      
      //get file name.
      String sFileName = this.getFileName(); //to display all space
      if (sFileName.length() > this.limitLength){
        sFileName = sFileName.substring(0,this.limitLength).replaceAll(" ", "&nbsp;")+"...";
      }
    
      //get onClick url.
      String onClickURL=this.getOnClickURL();
    
      if ( this.throughDocStatus == false && GlobalConstant.STATUS_INACTIVE.equals(recordStatus.trim())){ 
        printFileNameWithStyle(out,sStyle,sFileName);
      }else if (!GlobalConstant.RECORD_STATUS_ACTIVE.equals(this.docObject.getRecordStatus())) {
        printFileNameWithStyle(out,sStyle,sFileName);
      } else {
        imgURL=this.imgSrc("IconDMSEmailDoc.gif");
        this.printFileStyle(sStyle,sFileName,onClickURL,imgURL);
      }

    }catch(Exception e){}
  }
  /**
   * Method processed Form document.
   *
   */
  protected void processFormDoc(){
    try{
      this.setExtension("FORM");    
      super.doEndTag();
   
      DmsDocumentDAObject dmsDocmentDAO = new DmsDocumentDAObject(sessionContainer, conn);
      result = dmsDocmentDAO.getDocumentProfileInfo(this.docObject,sVersion);
    
      //get StringBuffer docInfo
      this.showHead();
      this.showArchvieInfo();
      this.showVersionInfo();
      this.showReferenceInfo(null);
      //this.showDefaultProfileInfo();
      this.showProfileInfo();
      this.showEndTable();
    
      String sStyle=this.getAlertFileNameStyle();      
      String imgURL="";
      
      //get file name.
      String sFileName = this.getFileName(); //to display all space
      if (sFileName.length() > this.limitLength){
        sFileName = sFileName.substring(0,this.limitLength).replaceAll(" ", "&nbsp;")+"...";
      }
      
      //get click url.
      String onClickURL=this.getOnClickURL();
    
      if (this.throughDocStatus == false && GlobalConstant.STATUS_INACTIVE.equals(recordStatus.trim())){ 
        printFileNameWithStyle(out,sStyle,sFileName);
      }else if (!GlobalConstant.RECORD_STATUS_ACTIVE.equals(this.docObject.getRecordStatus())) {
        printFileNameWithStyle(out,sStyle,sFileName);
      } else {
        imgURL=this.imgSrc("IconTreeEmailDocOpen.gif");
        this.printFileStyle(sStyle,sFileName,onClickURL,imgURL);
      }

    }catch(Exception e){}
  }
  
  /**
   * Method processed Workflow document.
   *
   */
  protected void processFlowDoc(){
    try{
      this.setExtension("WORKFLOW");    
      super.doEndTag();
   
      DmsDocumentDAObject dmsDocmentDAO = new DmsDocumentDAObject(sessionContainer, conn);
      result = dmsDocmentDAO.getDocumentProfileInfo(this.docObject,sVersion);
    
      //get StringBuffer docInfo
      this.showHead();
      this.showArchvieInfo();
      this.showVersionInfo();
      this.showReferenceInfo(null);
      //this.showDefaultProfileInfo();
      this.showProfileInfo();
      this.showEndTable();
    
      String sStyle=this.getAlertFileNameStyle();      
      String imgURL="";
      
      //get file name.
      String sFileName = this.getFileName(); //to display all space
      if (sFileName.length() > this.limitLength){
        sFileName = sFileName.substring(0,this.limitLength).replaceAll(" ", "&nbsp;")+"...";
      }
      
      //get click url.
      String onClickURL=this.getOnClickURL();
    
      if (this.throughDocStatus == false && GlobalConstant.STATUS_INACTIVE.equals(recordStatus.trim())){ 
        printFileNameWithStyle(out,sStyle,sFileName);
      }else if (!GlobalConstant.RECORD_STATUS_ACTIVE.equals(this.docObject.getRecordStatus())) {
        printFileNameWithStyle(out,sStyle,sFileName);
      } else {
        imgURL=this.imgSrc("IconTreeEmailDocOpen.gif");
        this.printFileStyle(sStyle,sFileName,onClickURL,imgURL);
      }

    }catch(Exception e){}
  }
  
  /**
   * Method showed head information.
   *
   */
  protected void showHead(){
    String temp=null;
      
    if (!Utility.isEmpty(result)) {
      for (int i = 0; i < result.size(); i++) {
        for (int j = 0; j < 3; j++) {
          temp = ((String[])result.get(i))[j];

          if (!Utility.isEmpty(temp)) {
            ((String[])result.get(i))[j] = TextUtility.escapeJSString(TextUtility.br(temp));
          } else {
            ((String[])result.get(i))[j] = "";
          }
        }
      }
    }

    docInfo.append("<table class=documentInfoTable>");
    //indicate if the document/folder is not yet effective

    // Show document/folder name.
    if(!Utility.isEmpty(result)){
      //if(((String[])result.get(0)).length>3){
      docInfo.append("  <tr>");
      docInfo.append("    <td class=documentInfoField>" + MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "dms.label.name_label_" + ((String[])result.get(0))[3]) + ": </td>"); // dms.label.name_label_<doc_type>   
      docInfo.append("    <td class=documentInfoValue>" + ((String[])result.get(0))[0] + "</td>");
      docInfo.append("  </tr>");
    }
  }
  
  /**
   * Method showed information of version number and version label
   *
   */
  protected void showVersionInfo(){
    //   Show current version.
    docInfo.append("  <tr>");
    docInfo.append("    <td class=documentInfoField>" + MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "dms.label.current_versions") + ": </td>"); // dms.label.number_of_versions
    docInfo.append("    <td class=documentInfoValue>" + ((String[])result.get(0))[2] + "</td>");
    docInfo.append("  </tr>");

    // Show no. of version.
    docInfo.append("  <tr>");
    docInfo.append("    <td class=documentInfoField>" + MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "dms.label.number_of_versions") + ": </td>"); // dms.label.number_of_versions
    docInfo.append("    <td class=documentInfoValue>" + ((String[])result.get(0))[1] + "</td>");
    docInfo.append("  </tr>");
  }
  
  /**
   * Method showed information of archived files
   *
   */
  protected void showArchvieInfo(){
    try{
      //        show archive status information
      if(DmsVersion.ARCHIVED_STATUS.equals(this.docObject.getItemStatus())){
        DmsArchiveDAObject dmsArchiveDAO  = new DmsArchiveDAObject(sessionContainer, conn);
        DmsArchiveDetailDAObject dmsArchiveDetailDAO = new DmsArchiveDetailDAObject(sessionContainer, conn);
        String archiveName ="";
        Integer tmpSegmentID = null;
        String segmentID ="";
        archiveName = dmsArchiveDAO.getArchiveNameByDocID(this.docObject.getID());
        tmpSegmentID =  dmsArchiveDetailDAO.getSegmentIDByDocID(this.docObject.getID());
        if(tmpSegmentID!=null){
          if(tmpSegmentID.intValue()<10){
            segmentID="00"+tmpSegmentID.toString();
          }else if(tmpSegmentID.intValue()>=10 && tmpSegmentID.intValue()<100){
            segmentID="0"+tmpSegmentID.toString();
          }else{
            segmentID=tmpSegmentID.toString().toString();
          }
        }

        //show the archive name
        docInfo.append("  <tr>");
        docInfo.append("    <td class=documentInfoField>" + MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "dms.label.archive_name") + ": </td>");
        docInfo.append("    <td class=documentInfoValue>" + archiveName + "</td>");
        docInfo.append("  </tr>");

        //show the archive segments
        docInfo.append("  <tr>");
        docInfo.append("    <td class=documentInfoField>" + MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "dms.label.archive_segment") + ": </td>"); // dms.label.number_of_versions
        docInfo.append("    <td class=documentInfoValue>" + segmentID + "</td>");
        docInfo.append("  </tr>");
      }
    }catch(Exception e){}
  }
  
  /**
   * Method showed information of reference no and description.
   * @param targetDoc
   */
  protected void showReferenceInfo(DmsDocument targetDoc){
  
    DocumentRetrievalManager docRetrievalManager = new DocumentRetrievalManager(sessionContainer, conn);	  
    //joan.xiong add code for bug EIP-414 by 2006/12/13
    if(!Utility.isEmpty(this.sVersion)){
    	docObject.setReferenceNo(((String[])result.get(0))[4]);
    	docObject.setDescription(((String[])result.get(0))[5]);
    }
    //joan.xiong add code end
    // Show reference no.
    docInfo.append("  <tr>");
    docInfo.append("    <td class=documentInfoField>" + MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "dms.label.reference_no") + ": </td>"); // dms.label.reference_no
    if (DmsDocument.DOCUMENT_LINK.equals(this.docObject.getDocumentType())) {
      if (targetDoc!=null){
        docInfo.append("    <td class=documentInfoValue>" + TextUtility.escapeJSString(TextUtility.plainTextToHtml(TextUtility.br(docObject.getReferenceNo()))) + "</td>");
      }
    }else{
      docInfo.append("    <td class=documentInfoValue>" + TextUtility.escapeJSString(TextUtility.plainTextToHtml(TextUtility.br(docObject.getReferenceNo()))) + "</td>");
    }
    docInfo.append("  </tr>");

    // Show description.
    docInfo.append("  <tr>");
    docInfo.append("    <td class=documentInfoField>" + MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "dms.label.description") + ": </td>"); // dms.label.description
    docInfo.append("    <td class=documentInfoValue>" + TextUtility.escapeJSString(TextUtility.plainTextToHtml(TextUtility.br(docObject.getDescription()))) + "</td>");
    docInfo.append("  </tr>");
    
    //show loacation of orginal document
    if(DmsDocument.DOCUMENT_LINK.equals(docObject.getDocumentType()) && targetDoc != null){
      try{
        docInfo.append("  <tr>");
        docInfo.append("    <td class=documentInfoField>" + MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(),"dms.label.orginal_location") + ": </td>");//dms.label.orginal_location
        docInfo.append("    <td class=documentInfoValue>" + TextUtility.escapeJSString(docRetrievalManager.getLocationPath(targetDoc.getParentID())) + "</td>");
        docInfo.append("  </tr>");    		
      }catch(Exception e){
        
      }
      
    }
  }
  
  /**
   * Method showd all information of default profile.
   *
   */
  protected void showDefaultProfileInfo(){
    try{
      com.dcivision.dms.core.DocumentRetrievalManager docRetrievalManager = new com.dcivision.dms.core.DocumentRetrievalManager(sessionContainer, conn);
   
      //Retrieve the default document profile settings.
      List dmsDefaultProfile = docRetrievalManager.checkNSetDefaultProfileList((javax.servlet.http.HttpServletRequest)pageContext.getRequest());

      // Show default profile information.
      if (!DmsDocument.DOCUMENT_LINK.equals(docObject.getDocumentType())) {
        int totalFieldCount = Integer.parseInt(SystemParameterFactory.getSystemParameter(SystemParameterConstant.DMS_DEFAULT_PROFILE_FIELD_COUNT));
        for (int i = 0; i < totalFieldCount; i++) {
          DmsDefaultProfileSetting setting = ((DmsDefaultProfileSetting)dmsDefaultProfile.get(i));
          String fieldValue = "";
          switch (i) {
            case 0:
              fieldValue = docObject.getUserDef1();
              break;
            case 1:
              fieldValue = docObject.getUserDef2();
              break;
            case 2:
              fieldValue = docObject.getUserDef3();
              break;
            case 3:
              fieldValue = docObject.getUserDef4();
              break;
            case 4:
              fieldValue = docObject.getUserDef5();
              break;
            case 5:
              fieldValue = docObject.getUserDef6();
              break;
            case 6:
              fieldValue = docObject.getUserDef7();
              break;
            case 7:
              fieldValue = docObject.getUserDef8();
              break;
            case 8:
              fieldValue = docObject.getUserDef9();
              break;
            case 9:
              fieldValue = docObject.getUserDef10();
              break;
          }
          if (DmsDefaultProfileSetting.FIELD_TYPE_DATE.equals(setting.getFieldType())){
            fieldValue=TextUtility.parseDBDateTime(fieldValue)==null? GlobalConstant.EMPTY_FIELD:TextUtility.parseDBDateTime(fieldValue);
          }
          docInfo.append("  <tr>");
          docInfo.append("    <td class=documentInfoField>" + setting.getFieldName() + ": </td>");
          docInfo.append("    <td class=documentInfoValue>" + TextUtility.noNull(TextUtility.escapeJSString(TextUtility.plainTextToHtml(TextUtility.br(TextUtility.plainTextToHtml(fieldValue))))) + "</td>");
          docInfo.append("  </tr>");
        }
      }
    }catch(Exception e){}
  }
  
  /**
   * Method showd all information of default profile.
   *
   */
  protected void showDefaultProfileInfo(DmsDocument dmsDocument){
    try{
      com.dcivision.dms.core.DocumentRetrievalManager docRetrievalManager = new com.dcivision.dms.core.DocumentRetrievalManager(sessionContainer, conn);
   
      //Retrieve the default document profile settings.
      List dmsDefaultProfile = docRetrievalManager.checkNSetDefaultProfileList((javax.servlet.http.HttpServletRequest)pageContext.getRequest());

      // Show default profile information.
      if (!DmsDocument.DOCUMENT_LINK.equals(docObject.getDocumentType()) && Utility.isEmpty(dmsDocument)) {
        int totalFieldCount = Integer.parseInt(SystemParameterFactory.getSystemParameter(SystemParameterConstant.DMS_DEFAULT_PROFILE_FIELD_COUNT));
        for (int i = 0; i < totalFieldCount; i++) {
          DmsDefaultProfileSetting setting = ((DmsDefaultProfileSetting)dmsDefaultProfile.get(i));
          String fieldValue = "";
          switch (i) {
            case 0:
              fieldValue = docObject.getUserDef1();
              break;
            case 1:
              fieldValue = docObject.getUserDef2();
              break;
            case 2:
              fieldValue = docObject.getUserDef3();
              break;
            case 3:
              fieldValue = docObject.getUserDef4();
              break;
            case 4:
              fieldValue = docObject.getUserDef5();
              break;
            case 5:
              fieldValue = docObject.getUserDef6();
              break;
            case 6:
              fieldValue = docObject.getUserDef7();
              break;
            case 7:
              fieldValue = docObject.getUserDef8();
              break;
            case 8:
              fieldValue = docObject.getUserDef9();
              break;
            case 9:
              fieldValue = docObject.getUserDef10();
              break;
          }
          if (DmsDefaultProfileSetting.FIELD_TYPE_DATE.equals(setting.getFieldType())){
            fieldValue=TextUtility.parseDBDateTime(fieldValue)==null? GlobalConstant.EMPTY_FIELD:TextUtility.parseDBDateTime(fieldValue);
          }
          docInfo.append("  <tr>");
          docInfo.append("    <td class=documentInfoField>" + setting.getFieldName() + ": </td>");
          docInfo.append("    <td class=documentInfoValue>" + TextUtility.noNull(TextUtility.escapeJSString(TextUtility.plainTextToHtml(TextUtility.br(TextUtility.plainTextToHtml(fieldValue))))) + "</td>");
          docInfo.append("  </tr>");
        }
      } else {
        int totalFieldCount = Integer.parseInt(SystemParameterFactory.getSystemParameter(SystemParameterConstant.DMS_DEFAULT_PROFILE_FIELD_COUNT));
        for (int i = 0; i < totalFieldCount; i++) {
          DmsDefaultProfileSetting setting = ((DmsDefaultProfileSetting)dmsDefaultProfile.get(i));
          String fieldValue = "";
          switch (i) {
            case 0:
              fieldValue = dmsDocument.getUserDef1();
              break;
            case 1:
              fieldValue = dmsDocument.getUserDef2();
              break;
            case 2:
              fieldValue = dmsDocument.getUserDef3();
              break;
            case 3:
              fieldValue = dmsDocument.getUserDef4();
              break;
            case 4:
              fieldValue = dmsDocument.getUserDef5();
              break;
            case 5:
              fieldValue = dmsDocument.getUserDef6();
              break;
            case 6:
              fieldValue = dmsDocument.getUserDef7();
              break;
            case 7:
              fieldValue = dmsDocument.getUserDef8();
              break;
            case 8:
              fieldValue = dmsDocument.getUserDef9();
              break;
            case 9:
              fieldValue = dmsDocument.getUserDef10();
              break;
          }
          if (DmsDefaultProfileSetting.FIELD_TYPE_DATE.equals(setting.getFieldType())){
            fieldValue=TextUtility.parseDBDateTime(fieldValue)==null? GlobalConstant.EMPTY_FIELD:TextUtility.parseDBDateTime(fieldValue);
          }
          docInfo.append("  <tr>");
          docInfo.append("    <td class=documentInfoField>" + setting.getFieldName() + ": </td>");
          docInfo.append("    <td class=documentInfoValue>" + TextUtility.noNull(TextUtility.escapeJSString(TextUtility.plainTextToHtml(TextUtility.br(TextUtility.plainTextToHtml(fieldValue))))) + "</td>");
          docInfo.append("  </tr>");
        }
      }
    }catch(Exception e){}
  }
  
  /**
   * Method showed information of user define profile.
   *
   */
  protected void showProfileInfo(){
    // Show document profile(s) information.
    for (int i = 1; i<result.size(); i++) {
      String[] saInfo = (String[])result.get(i);
      String sCurrent = ((String[])result.get(i))[0];
      String sPrevious = ((String[])result.get(i-1))[0];
      if (!(sCurrent.equals(sPrevious))){
        docInfo.append("  <tr>");
        docInfo.append("    <td class=documentInfoField>" + MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "dms.label.profile_name") + ": </td>"); // dms.label.profile_name
        docInfo.append("    <td class=documentInfoValue>"+ TextUtility.escapeJSString(TextUtility.plainTextToHtml(saInfo[0])) + "</td>");
        docInfo.append("  </tr>");
      }
      if (!Utility.isEmpty(saInfo[0]) && !Utility.isEmpty(saInfo[1])){
        docInfo.append("  <tr>");
        docInfo.append("    <td class=documentInfoField>"+ TextUtility.escapeJSString(TextUtility.plainTextToHtml(saInfo[1])) + ": </td>");
        docInfo.append("    <td class=documentInfoValue>"+ TextUtility.escapeJSString(TextUtility.plainTextToHtml(saInfo[2])) + "</td>");
        docInfo.append("  </tr>");
      }
    }     
  }
  
  /**
   * Method showd end table.
   *
   */
  protected void showEndTable(){
    docInfo.append("</table>");
  }
  
  /**
   * Method got onClick url form document name.
   * @return string
   */
  protected String getOnClickURL(){
    String onClickURL="";
    try{
      Integer docID = docObject.getID();
      String sExt = this.getExtension();
      
      if (Utility.isEmpty(sCurFunctionCode)){
        sCurFunctionCode = (String)pageContext.getRequest().getAttribute(GlobalConstant.FUNCTION_CODE_KEY);
      }
      
      /* Document Info Tag; on click URL */
      if (Utility.isEmpty(recordStatus)) {
        recordStatus = docObject.getRecordStatus();
      }
      
      if (this.throughDocStatus == false && GlobalConstant.STATUS_INACTIVE.equals(recordStatus)) {
        out.print("<strike>");
      }
      if(Utility.isEmpty(sVersion)){
        sVersion = DmsOperationConstant.DMS_TOP_VERSION;
      }
      if (!bPopupFlag){
        //modify by beyond ,add  document name after FileDownloadServlet , bug id is EIP-253
        onClickURL ="'"+ contextPath + "/dms/FileDownloadServlet/"+TextUtility.getURLEncodeInUTF8(docObject.getDocumentName())+"?sCurFunctionCode=" + sCurFunctionCode + "&targetID=" + docID + "&version=" + sVersion + "&ext=." + sExt + "&updateReadOperation="+ updateReadOperation+ "&updateAlertSystemLogID="+updateAlertSystemLogID;
        onClickURL = onClickURL.concat("' ");
      } else {
        onClickURL ="'"+ contextPath + "/dms/FileDownloadServlet/"+TextUtility.getURLEncodeInUTF8(docObject.getDocumentName())+"?sCurFunctionCode=" + sCurFunctionCode + "&targetID=" + docID + "&version=" + sVersion + "&ext=." + sExt + "&updateReadOperation="+ updateReadOperation+ "&updateAlertSystemLogID="+updateAlertSystemLogID;
        /* Update Alert READ Action */
        if (this.updateAlertSystemLogID!=null) {
          onClickURL=onClickURL.concat("&updateAlertID=" + updateAlertID + "&updateAlertTypeID=" + updateAlertTypeID+ "&updateAlertSystemLogID=" + updateAlertSystemLogID);
        }
        onClickURL = onClickURL.concat("' ");

        if (DmsOperationConstant.DMS_RECORD_EMPTY.equals(recordStatus)){
          onClickURL = "'MaintDmsCheckout.do?opMode="+DmsOperationConstant.CHECKOUT_CHECK+"&documentID="+docObject.getID()+"&parentID="+docObject.getParentID()+"&rootID="+docObject.getRootID()+"&curFunctionCode="+sCurFunctionCode+"' ";
        }

        //get the onClickURL where bLinkFlag=true
        if(DmsDocument.EMAIL_DOC_TYPE.equals(docObject.getDocumentType())){
          onClickURL="'"+contextPath+"/dms/MaintDmsEmailDocument.do?rootID=" + docObject.getRootID() + "&parentID=" + docObject.getParentID() +
          "&sCurFunctionCode="+sCurFunctionCode+"&navMode="+GlobalConstant.NAV_MODE_PREVIEW+"&ID="+docID+"&objectID="+docID + "&updateReadOperation="+ updateReadOperation + "&updateAlertSystemLogID="+updateAlertSystemLogID+"' ";  
        }else if (DmsDocument.DOCUMENT_LINK.equals(docObject.getDocumentType())){
          DmsDocumentDAObject dmsDocmentDAO = new DmsDocumentDAObject(sessionContainer, conn);
          com.dcivision.dms.core.DocumentRetrievalManager docRetrievalManager = new com.dcivision.dms.core.DocumentRetrievalManager(sessionContainer, conn);
          try{
            DmsDocument targetDoc = null;
            if (GlobalConstant.RECORD_STATUS_INACTIVE.equals(this.docObject.getRecordStatus())){
              MtmDocumentRelationshipDAObject relationshipDAO = new MtmDocumentRelationshipDAObject(sessionContainer, conn);
              List relationshipIDs = relationshipDAO.getInactiveListByRelationID(this.docObject.getID(),DmsDocument.DOCUMENT_LINK,GlobalConstant.RECORD_STATUS_INACTIVE);
              Integer relationshipID = null;
              if (!Utility.isEmpty(relationshipIDs) && relationshipIDs.size() > 0){
                MtmDocumentRelationship mtmDoc = (MtmDocumentRelationship)relationshipIDs.get(0);
                relationshipID = mtmDoc.getDocumentID();
              }
              targetDoc = (DmsDocument)dmsDocmentDAO.getByIDRecordStatus(relationshipID,null);    
            } else {
              targetDoc =docRetrievalManager.getRelationshipTargetDocument(this.docObject.getID(),this.docObject.getDocumentType());
            }
            if (DmsDocument.EMAIL_DOC_TYPE.equals(targetDoc.getDocumentType())){
              onClickURL="'"+contextPath+"/dms/MaintDmsEmailDocument.do?rootID=" + targetDoc.getRootID() + "&parentID=" + targetDoc.getParentID() +
              "&sCurFunctionCode="+sCurFunctionCode+"&navMode="+GlobalConstant.NAV_MODE_PREVIEW+"&ID="+targetDoc.getID()+"&objectID="+targetDoc.getID() + "&updateReadOperation="+ updateReadOperation + "&updateAlertSystemLogID="+updateAlertSystemLogID+"' ";
            } else {
              onClickURL="'"+contextPath+"/dms/MaintDmsDocument.do?documentType="+docObject.getDocumentType()+"&rootID=" + docObject.getRootID() + "&parentID=" + docID +
              "&sCurFunctionCode="+sCurFunctionCode+"&navMode="+GlobalConstant.NAV_MODE_PREVIEW+"&ID="+docID+"&objectID="+docID + "&updateReadOperation="+ updateReadOperation + "&updateAlertSystemLogID="+updateAlertSystemLogID+"' ";
            }
          } catch (Exception e) {
            log.error(e, e);
          }
        }else{
          onClickURL="'"+contextPath+"/dms/MaintDmsDocument.do?documentType="+docObject.getDocumentType()+"&rootID=" + docObject.getRootID() + "&parentID=" + docID +
                          "&sCurFunctionCode="+sCurFunctionCode+"&navMode="+GlobalConstant.NAV_MODE_PREVIEW+"&ID="+docID+"&objectID="+docID + "&updateReadOperation="+ updateReadOperation + "&updateAlertSystemLogID="+updateAlertSystemLogID+"' ";
        }
      }
    }catch(IOException e){}
    return onClickURL;
  }
  
  /**
   * print deferent style of file name.
   * @param out
   * @param sStyle
   * @param sFileName
   * @throws Exception
   */
  private void printFileNameWithStyle(JspWriter out,String sStyle,String sFileName) throws Exception{
    docInfo = new StringBuffer();
    docInfo.append("<table border=0 cellpadding=0 cellspacing=1>");
    docInfo.append("  <tr>");
    docInfo.append("    <td>" + MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "dms.label.name_label_" + ((String[])result.get(0))[3]) + ": </td>");
    docInfo.append("    <td>" + ((String[])result.get(0))[0] + "</td>");
    docInfo.append("  </tr>");
    docInfo.append("</table>");

    out.print(" <a onmouseover=\"return getDocumentInfo('"+docInfo.toString()+"');\" ");
    out.print("    onmouseout=\"return nd();\">");
    if(sStyle!=null) {
      out.print("<font class='");
      out.print(sStyle);
      out.print("'>");
      out.print(sFileName);
      out.print("</font>");
    }else{
      out.print(sFileName);
    }
    out.print("</a>");   
  }
  
  /**
   * print font of file name.
   * @param out
   * @param sFileName
   * @param sStyle
   * @throws Exception
   */
  private void printFontFileName(JspWriter out, String sFileName, String sStyle) throws Exception{
    if(sStyle!=null) {
      out.print("<font class='");
      out.print(sStyle);
      out.print("'>");
      out.print(sFileName);
      out.print("</font>");
    }else{
      out.print(sFileName);
    }
  }

  private void printFileName(JspWriter out,String sFileName) throws Exception{
    printFileNameWithStyle(out,null,sFileName);
  }

  public void release() {
    docObject = null;
    recordStatus = null;
    hasUnderLine = true;
    limitLength = -1;
    isLimitLength = true;
    super.release();
  }
  
  /**
   * 
   * @param sStyle
   * @param sFileName
   * @param onClickURL
   * @param imgURL
   */
  protected void printFileStyle(String sStyle,String sFileName,String onClickURL,String imgURL){
    String jsPopupSuffix="";
    Integer  listLoopCnt = (Integer)pageContext.getAttribute("listLoopCnt");
        
    if (listLoopCnt != null) {
      jsPopupSuffix = ", " + listLoopCnt.toString();
    }
    try{
      com.dcivision.dms.core.DocumentRetrievalManager docRetrievalManager = new com.dcivision.dms.core.DocumentRetrievalManager(sessionContainer, conn);  
      DmsDocument targetDocument = null;
      if (DmsDocument.DOCUMENT_LINK.equals(docObject.getDocumentType())) {
        targetDocument=docRetrievalManager.getRelationshipTargetDocument(docObject.getID(),DmsDocument.DOCUMENT_LINK,GlobalConstant.RECORD_STATUS_ACTIVE);
      }
      boolean isTargetArchived = DmsDocument.DOCUMENT_LINK.equals(this.docObject.getDocumentType()) && (targetDocument!=null && DmsVersion.ARCHIVED_STATUS.equals(targetDocument.getItemStatus()));
      boolean isTargetNoReadRight = DmsDocument.DOCUMENT_LINK.equals(this.docObject.getDocumentType()) && ((this.sessionContainer.getPermissionManager().getDocumentLinkPermission(conn, this.docObject.getID())).indexOf("R")==-1);
      
      //if (!DmsVersion.ARCHIVED_STATUS.equals(docObject.getItemStatus())) {
      if (bOnClick && (((!Utility.isEmpty(sPermission) && sPermission.indexOf("R")>=0) || bInviteToRead) && (!docObject.isExpired() || sessionContainer.getUserRecordID().equals(docObject.getOwnerID())))) {
        if (bShowIndexFlag) {
          if (isOverLib) {
            //when isOverLib is true,not show the index
            printFileNameWithStyle(out,sStyle,sFileName);
          } else {
            StringBuffer sbLink = new StringBuffer();
            
            //reference file , not show the links
            if(!(isTargetArchived || isTargetNoReadRight) && !DmsOperationConstant.DMS_RECORD_EMPTY.equals(docObject.getRecordStatus())&&!docObject.isExpired()){
              if(!bLinkFlag){
                if(GlobalConstant.STATUS_INACTIVE.equals(recordStatus.trim()) || DmsDocument.PAPER_DOC_TYPE.equals(docObject.getDocumentType())){
                  sbLink.append(" <a ");  
                }else if(DmsDocument.DOCUMENT_LINK.equals(docObject.getDocumentType())){
                  if(targetDocument==null){
                    //tarDoc = docObject;
                    sbLink.append(" <a href=");
                    sbLink.append("\"#\" onClick=\"return(shortcutPopupWarning("+docObject.getID()+"));\"");
                  }else{
                    if(DmsDocument.PAPER_DOC_TYPE.equals(targetDocument.getDocumentType())){
                      sbLink.append(" <a ");
                    } else if (DmsDocument.EMAIL_DOC_TYPE.equals(targetDocument.getDocumentType())) {
                      out.print(" <a href=");
                      if (bPopupFlag){
                        sbLink.append("\"#\" onClick=\"return(popupDocument("+targetDocument.getID()+","+onClickURL+", 'DCIVisionDocumentSummary', 780, 570, 'status=no,menubar=no,scrollbars=yes,resizable=yes,toolbar=no'"+jsPopupSuffix+",'"+targetDocument.getDocumentType()+"'));\"");
                      } else {
                        sbLink.append(onClickURL);
                      }
                    } else{
                      out.print(" <a href=");
                      if (bPopupFlag){
                        sbLink.append("\"#\" onClick=\"return(popupDocument("+docObject.getID()+","+onClickURL+", 'DCIVisionDocumentSummary', 780, 570, 'status=no,menubar=no,scrollbars=yes,resizable=yes,toolbar=no'"+jsPopupSuffix+",'"+docObject.getDocumentType()+"'));\"");
                      } else {
                        sbLink.append(onClickURL);
                      } 
                    } 
                  }
                }else{
                  if(!docObject.getItemStatus().equals("R")){
                    sbLink.append(" <a href=");
                    if (bPopupFlag){
                      sbLink.append("\"#\" onClick=\"return(popupDocument("+docObject.getID()+","+onClickURL+", 'DCIVisionDocumentSummary', 780, 570, 'status=no,menubar=no,scrollbars=yes,resizable=yes,toolbar=no'"+jsPopupSuffix+",'"+docObject.getDocumentType()+"'));\"");
                    } else {
                      sbLink.append(onClickURL);
                    } 
                  }
                }
              }else{
                sbLink.append(" <a href=");
                if(DmsDocument.DOCUMENT_LINK.equals(docObject.getDocumentType())){
                  DmsDocument tarDoc=docRetrievalManager.getRelationshipTargetDocument(docObject.getID(),DmsDocument.DOCUMENT_LINK,GlobalConstant.RECORD_STATUS_ACTIVE);
                  if(tarDoc==null){
                    //tarDoc = docObject;
                    sbLink.append("\"#\" onClick=\"return(shortcutPopupWarning("+docObject.getID()+"));\"");
                  }else{
                    if (bPopupFlag){
                      if (DmsDocument.EMAIL_DOC_TYPE.equals(tarDoc.getDocumentType())){
                        sbLink.append("\"#\" onClick=\"return(popupDocument("+tarDoc.getID()+","+onClickURL+", 'DCIVisionDocumentSummary', 780, 570, 'status=no,menubar=no,scrollbars=yes,resizable=yes,toolbar=no'"+jsPopupSuffix+",'"+tarDoc.getDocumentType()+"'));\"");
                      } else {
                        sbLink.append("\"#\" onClick=\"return(popupDocument("+docObject.getID()+","+onClickURL+", 'DCIVisionDocumentSummary', 780, 570, 'status=no,menubar=no,scrollbars=yes,resizable=yes,toolbar=no'"+jsPopupSuffix+",'"+docObject.getDocumentType()+"'));\"");
                      }
                    } else {
                      sbLink.append(onClickURL);
                    } 
                  } 
                }else{
                  if (bPopupFlag){
                    sbLink.append("\"#\" onClick=\"return(popupDocument("+docObject.getID()+","+onClickURL+", 'DCIVisionDocumentSummary', 780, 570, 'status=no,menubar=no,scrollbars=yes,resizable=yes,toolbar=no'"+jsPopupSuffix+",'"+docObject.getDocumentType()+"'));\"");
                  } else {
                    sbLink.append(onClickURL);
                  }
                }
              }
            }else {
              sbLink.append(" <a ");
            }
            if(this.getShowIndexLayer()){
              sbLink.append(" onmouseover=\"return getDocumentInfo('" +docInfo.toString() + "');\" onmouseout=\"return nd();\"");
            }else if(!docObject.getItemStatus().equals("R")){
              sbLink.append(" onmouseover=\"return getDocumentInfo('" +docInfo.toString() + "');\" onmouseout=\"return nd();\"");
            }
            if(sbLink.length()>0){
              sbLink.append(">");
            }
            out.print(" "+sbLink.toString());
            this.printFontFileName(out,sFileName,sStyle);
            if(sbLink.length()>0){
              out.print("</a>");
            }
          }//end else
        } else {
          if (!(isTargetArchived || isTargetNoReadRight)) {
            out.print(" <a href=");
            if (bPopupFlag){
              out.print("\"#\" onClick=\"return(popupDocument("+docObject.getID()+"," + onClickURL + ", 'DCIVisionDocumentSummary', 780, 570, 'status=no,menubar=no,scrollbars=yes,resizable=yes,toolbar=no'"+jsPopupSuffix+",'"+docObject.getDocumentType()+"'));\"");
            } else {
              out.print(onClickURL);
            }
            out.print(" onmouseover=\"return(false);\">");
            this.printFontFileName(out,sFileName,sStyle);
            out.println("</a>");
          }else {
            this.printFontFileName(out,sFileName,sStyle);
          }
        }
      } else {
        if (hasUnderLine) {
          printFileNameWithStyle(out,sStyle,sFileName);
        } else {
          if (bShowIndexFlag) {
            StringBuffer sbLink = new StringBuffer();
            if(this.getShowIndexLayer() || !docObject.getItemStatus().equals("R")){
              sbLink.append("<span onmouseover=\"return getDocumentInfo('" +docInfo.toString() + "');\" onmouseout=\"return nd();\"");
            }
            if(sbLink.length()>0){
              sbLink.append(">");
            }
            out.print(" "+sbLink.toString());
            printFontFileName(out,sFileName,sStyle);
            if(sbLink.length()>0){
              out.print("</span>");
            }
          }
        }
      }
     }catch(Exception e){}
  }
  
  /**
   * print style of file name for folder's short cut document.
   * @param sFileName
   * @param sStyle
   */
  protected void printFolderShortFileName(String sFileName,String sStyle){
    try{ 
      com.dcivision.dms.core.DocumentRetrievalManager docRetrievalManager = new com.dcivision.dms.core.DocumentRetrievalManager(sessionContainer, conn);
      DmsDocument targetDoc=docRetrievalManager.getRelationshipTargetDocument(this.docObject.getID(), this.docObject.getDocumentType(),GlobalConstant.RECORD_STATUS_ACTIVE);
                
      boolean targetDocDeleted = false;
      if(targetDoc==null){
        targetDoc = docObject;
        targetDocDeleted = true;
      }
                
      Integer RootIDtemp =targetDoc.getRootID();
              
      DmsRootDAObject dmsRootDAObject = new DmsRootDAObject(sessionContainer,conn);
      DmsRoot documentRoot = (DmsRoot)dmsRootDAObject.getObjectByID(RootIDtemp);
              
      //For Personal Folder
      if (documentRoot!=null && DmsOperationConstant.DMS_PERSONAL_ROOT.equals(documentRoot.getRootName())) { 
        if(docObject.getCreatorID().equals(sessionContainer.getUserRecordID())){
          if (bOnClick && ((sPermission.indexOf("R")>=0 || bInviteToRead) && (!docObject.isExpired() || sessionContainer.getUserRecordID().equals(docObject.getOwnerID())))) { 
            if (bOnClick) {
              if (!DmsOperationConstant.USE_DOC_FOLDER_PICKER.equals(this.getPageFlag())){
                String href = contextPath + "/dms/ListDmsDocument.do?rootID=" + RootIDtemp + "&parentID=" + targetDoc.getID() + "&curFunctionCode=" + SystemFunctionConstant.DMS_PERSONAL_FOLDER;
                String onclick = " onclick=\"return checkWindowForAction(\'"+href+"\');\"";
                href = " href=\"" + href + "\"";
                if(!targetDocDeleted){
                  if (this.isCheckWindowForAction()){
                    href = " href=\"#\"";
                  }else{
                    onclick = "";
                  }
                }else{
                  href="";
                  onclick="";
                }
                out.print(" <a " + href + " "+onclick);
                out.print("   onmouseover=\"return getDocumentInfo('" + docInfo.toString() + "');\" ");
                out.print("   onmouseout=\"return nd();\">" + sFileName + "</a>");
              }else{
                printFileName(out,sFileName);
              }
            } else {
              printFileName(out,sFileName);
            }
          }else{
            printFileName(out,sFileName);
          }
        }else{
          if (bOnClick && ((sPermission.indexOf("R")>=0 || bInviteToRead) && (!docObject.isExpired() || sessionContainer.getUserRecordID().equals(docObject.getOwnerID())))) {
            if (bOnClick) {
              out.print(sFileName);
            } else {
              printFileName(out,sFileName);  
            }
          }
        }
      } else {
        //For Public Folder
        if (bOnClick && ((sPermission.indexOf("R")>=0 || bInviteToRead) && (!docObject.isExpired() || sessionContainer.getUserRecordID().equals(docObject.getOwnerID())))) {
          if (!DmsOperationConstant.USE_DOC_FOLDER_PICKER.equals(this.getPageFlag())){
            String href = contextPath + "/dms/ListDmsPublicDocument.do?rootID=" + targetDoc.getRootID() + "&parentID=" + targetDoc.getID() + "&curFunctionCode=" + SystemFunctionConstant.DMS_PUBLIC_FOLDER + "&myPage=" + this.getPageFlag();
            String onclick = " onclick=\"return checkWindowForAction(\'"+href+"\');\"";
            href = " href=\"" + href + "\"";
            if(!targetDocDeleted){
              if(this.isCheckWindowForAction()){
                href=" href=\"#\"";
              }else{
                onclick="";
              }     
            }else{
              href="";
              onclick="";
            }
            out.print(" <a " + href + " "+onclick);
            out.print("   onmouseover=\"return getDocumentInfo('" + docInfo.toString() + "');\" ");
            out.print("   onmouseout=\"return nd();\">");
            this.printFontFileName(out,sFileName,sStyle);
            out.println("</a>");         
          }else{
            out.print(sFileName);
          }
        } else {
          if (hasUnderLine){
            printFileName(out,sFileName);
          } else {
            printFontFileName(out,sFileName,sStyle);
          }
        }
      }
    }catch(Exception e){}
  }

  /**
   * get alerted doc's style.
   * @param sessionContainer
   * @param conn
   * @return
   */
  protected String getAlertFileNameStyle(){
    String sStyle="";
    try{
      AlertManager am = new AlertManager(sessionContainer, conn);
      boolean alertOwnerRecord = false;
      boolean inviteOwnerRecord = false;
      if ( getDocObject().getAlertEditID()!=null){
        alertOwnerRecord = am.checkAlertOwner(getDocObject().getID(), sessionContainer.getUserRecordID(), null);
      }
      if (getDocObject().getAlertInviteID()!=null){
        inviteOwnerRecord =  am.checkAlertOwner(getDocObject().getID(), sessionContainer.getUserRecordID(), UpdateAlert.INVITE_TYPE);
      }
      am.release();

      if ( DmsVersion.ARCHIVED_STATUS.equals(getDocObject().getItemStatus()) ) {
        if (hasUnderLine) {
          sStyle = "archive";
        }else{
          sStyle = "archive-no-underline";
        }
      } else {
        //Check for the alert and invite case
        if (alertOwnerRecord && inviteOwnerRecord) {
          if (hasUnderLine) {
            sStyle = "alertInvite";
          } else {
            sStyle = "alertInvite-no-underline";
          }
        } else {
          if (alertOwnerRecord) {
            if (hasUnderLine){
              sStyle = "alertEdit";
            } else {
              sStyle = "alertEdit-no-underline";
            }
          }
          if (inviteOwnerRecord) {
            if (hasUnderLine) {
              sStyle = "alertInvite";
            } else {
              sStyle = "alertInvite-no-underline";
            }
          }
        }
      }
      if (!hasUnderLine && Utility.isEmpty(sStyle)) {
        sStyle = "no-underline";
      }
    }catch(Exception e){}
    return sStyle;
  }
  
  /**
   * Method to print folder.
   * @param sFileName
   * @param sStyle
   */
  private void printFolderURL(String sFileName,String sStyle){
    try{
      DmsRootDAObject dmsRootDAObject = new DmsRootDAObject(sessionContainer,conn);
      DmsRoot documentRoot = (DmsRoot)dmsRootDAObject.getObjectByID(docObject.getRootID()); 
      Integer docID=docObject.getID();
           
     //if (DmsOperationConstant.DMS_PERSONAL_ROOT.equals(documentRoot.getRootName())) {
     if (SystemFunctionConstant.DMS_PERSONAL_FOLDER.equals(sCurFunctionCode)|| (documentRoot!=null && DmsOperationConstant.DMS_PERSONAL_ROOT.equals(documentRoot.getRootName()))){
       //For Personal Folder
       if (bOnClick) {
         if (!DmsOperationConstant.USE_DOC_FOLDER_PICKER.equals(this.getPageFlag())){
           if("listDmsAuditTrail".equals(this.getPageFlag())&&!docObject.getCreatorID().equals(sessionContainer.getUserRecordID())){
             out.print(sFileName);
           }else{
             String href=contextPath + "/dms/ListDmsDocument.do?rootID=" + docObject.getRootID() + "&parentID=" + docID + "&curFunctionCode=" + SystemFunctionConstant.DMS_PERSONAL_FOLDER + "&myPage=" + this.getPageFlag();
             String onclick=" onclick=\"return checkWindowForAction(\'"+href+"\');\"";
             if(this.isCheckWindowForAction()){
               href="#";
             }else{
               onclick="";
             }
             out.print(" <a href=\""+href+"\" "+onclick);
             out.print("   onmouseover=\"return getDocumentInfo('" + docInfo.toString() + "');\" ");
             out.print("   onmouseout=\"return nd();\">" + sFileName + "</a>");
           }
         }else{
           out.print(sFileName);
         }
       } else {
         if (hasUnderLine) {
           printFileName(out,sFileName);
         } else {
           printFontFileName(out,sFileName,sStyle);
         }
       }
     } else {
       //For Public Folder
       if (bOnClick && ((sPermission.indexOf("R")>=0 || bInviteToRead) && (!docObject.isExpired() || sessionContainer.getUserRecordID().equals(docObject.getOwnerID())))) {
         String href=contextPath + "/dms/ListDmsPublicDocument.do?rootID=" + docObject.getRootID() + "&parentID=" + docID + "&curFunctionCode=" + SystemFunctionConstant.DMS_PUBLIC_FOLDER + "&myPage=" + this.getPageFlag();
         String onclick = " onclick=\"return checkWindowForAction(\'"+href+"\');\" ";
         if (this.isCheckWindowForAction()){
           href="#";
         }else{
           if(GlobalConstant.STATUS_INACTIVE.equals(recordStatus.trim())){
             href="#";
             onclick="";
           }else{
             onclick="";
           }
         }
         out.print(" <a href=\"" + href + "\" "+onclick);
         out.print("    onmouseover=\"return getDocumentInfo('" + docInfo.toString() + "');\" ");
         out.print("    onmouseout=\"return nd();\">");
         this.printFontFileName(out,sFileName,sStyle);
         out.println("</a>");
       } else {
         if (hasUnderLine) {
           printFileName(out,sFileName);
         } else {
           if (bShowIndexFlag) {
             StringBuffer sbLink = new StringBuffer();
             if(this.getShowIndexLayer() || !"R".equals(docObject.getItemStatus())){
               sbLink.append("<span onmouseover=\"return getDocumentInfo('" +docInfo.toString() + "');\" onmouseout=\"return nd();\"");
             }
             if(sbLink.length()>0){
               sbLink.append(">");
             }
             out.print(" "+sbLink.toString());
             printFontFileName(out,sFileName,sStyle);
             if(sbLink.length()>0){
               out.print("</span>");
             }
           }
         }
       }
     }
    }catch(Exception e){}
  }

  public boolean isCheckWindowForAction() {
    return checkWindowForAction;
  }

  public void setCheckWindowForAction(boolean checkWindowForAction) {
    this.checkWindowForAction = checkWindowForAction;
  }

  public boolean getIsLimitLength() {
    return isLimitLength;
  }

  public void setIsLimitLength(boolean isLimitLength) {
    this.isLimitLength = isLimitLength;
  }

  public boolean isHasUnderLine() {
    return hasUnderLine;
  }

  public void setHasUnderLine(boolean hasUnderLine) {
    this.hasUnderLine = hasUnderLine;
  }
  
}
